<template>
  <div class="wrapper">
    <!--轮播区域 -->
    <swiper ref="mySwiper" :options="swiperOptions" v-if="showSwiper">
      <swiper-slide v-for="item in swiper" :key="item.id">
        <img class="swiperImg" :src="item.imgUrl" alt="">
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  props: ['swiper'],
  data: function () {
    return {
      swiperOptions: {
        pagination: '.swiper-pagination',
        loop: true,
        autoplay: 3000,
        speed: 2000
      }
    }
  },
  computed: {
    showSwiper: function () {
      return this.swiper.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active {
    background: #fff
  }

  .wrapper {
    overflow: hidden
    width: 100%
    height: 0
    padding-bottom: 30%
    background: #eee

    .swiperImg {
      width 100%
    }
  }
</style>
